package com.lcx.movie.service.impl;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lcx.movie.entity.Comment;
import com.lcx.movie.mapper.CommentMapper;
import com.lcx.movie.service.CommentService;

import java.util.List;

/**
 * @Description  评论实现类
 * @version 1.0 
 * @author lcx
 * @date 2025/2/9 11:25
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService{
    @Autowired
    private CommentMapper commentMapper;
    /**
     * 根据电影id查询出电影评论,展示评论对应的用户头像
     * @param movieId 电影id
     * @return 评论集合
     */
    @Override
    public List<Comment> selectCommentsByMovieId(Integer movieId){
        return commentMapper.selectCommentsByMovieId(movieId);
    }
    /**
     * 新增评论
     * @param comment 评论实体
     * @return 受影响的行数
     */
    @Override
    public int insertComment(Comment comment){
        return commentMapper.insertComment(comment);
    }

    /**
     * 删除评论[前端]
     * @param commentId 评论id
     * @return 受影响的行数
     */
    @Override
    public int deleteComment(Integer commentId){
        return commentMapper.deleteComment(commentId);
    }

    /**
     * //分页模糊查询评论表
     * @param userName 用户名
     * @return 评论集合
     */
    @Override
    public List<Comment> selectCommentPage(String userName) {
        return this.baseMapper.selectCommentPage(userName);
    }

    /**
     * //详细查询评论表
     * @param commentId 评论id
     * @return 评论对象
     */
    @Override
    public Comment selectCommentId(int commentId) {
        return this.baseMapper.selectCommentId(commentId);
    }

    /**
     * //修改评论表
     * @param comment 评论实体
     * @return 字符串提示信息
     */
    @Override
    public String updateComment(Comment comment) {
        return this.baseMapper.updateComment(comment)>0?"修改成功":"修改失败";
    }

    /**
     * //删除评论
     * @param commentId 评论id
     * @return 字符串提示信息
     */
    @Override
    public String deleteCommentId(int commentId) {
        return this.baseMapper.deleteCommentId(commentId)>0?"删除成功":"删除失败";
    }
}
